package data;

import java.sql.*;

public class Grid extends DataElement
{
	public int param_precision_digits;
	public int param_geographic_accuracy;
	public int param_temporal_accuracy;
	public double phys_axial_tilt;
	public double phys_orbital_eccentricity;
	public double sim_grid_spacing;
	public int sim_time_step;
	
	public Grid( DataFactory factory )
	{
	    super( factory );
	}
	
	protected String valuesString()
	{
		return "" + param_precision_digits + ", " +
					param_geographic_accuracy + ", " + 
					param_temporal_accuracy + ", " +
					phys_axial_tilt + ", " +
					phys_orbital_eccentricity + ", " +
					sim_grid_spacing + ", " +
					sim_time_step;
	}
	
	protected void _loadFrom( ResultSet rs ) throws SQLException
	{
		param_precision_digits = rs.getInt( "param_precision_digits" );
		param_geographic_accuracy = rs.getInt( "param_precision_digits" );
		param_temporal_accuracy = rs.getInt( "param_temporal_accuracy" );
		phys_axial_tilt = rs.getDouble( "phys_axial_tilt" );
		phys_orbital_eccentricity = rs.getDouble( "phys_orbital_eccentricity" );
		sim_grid_spacing = rs.getDouble( "sim_grid_spacing" );
		sim_time_step = rs.getInt( "sim_time_step" );
	}
	
	protected String _insert()
	{
		return "(param_precision_digits, param_geographic_accuracy, param_temporal_accuracy, phys_axial_tilt, phys_orbital_eccentricity, sim_grid_spacing, sim_time_step) values (" +
			param_precision_digits + ", " +
			param_geographic_accuracy + ", " + 
			param_temporal_accuracy + ", " +
			phys_axial_tilt + ", " +
			phys_orbital_eccentricity + ", " +
			sim_grid_spacing + ", " +
			sim_time_step + "); select nextval('grids_id_seq');";
	}
	protected String _update()
	{
		return "param_precision_digits=" + param_precision_digits +
			", param_geographic_accuracy=" + param_geographic_accuracy +
			", param_temporal_accuracy=" + param_temporal_accuracy +
			", phys_axial_tilt=" + phys_axial_tilt +
			", phys_orbital_eccentricity=" + phys_orbital_eccentricity +
			", sim_grid_spacing=" + sim_grid_spacing +
			", sim_time_step=" + sim_time_step;
	}
}
